#pragma once

#include "stdafx.h"
#include "MessageSubscriber.h"
#include "World.h"
#include "MainMenu.h"
#include "DemoMenu.h"
#include "MessageArray.h"
#include "AboutDialog.h"

//TODO:
//    Refractor.
//    This class has taken too many jobs.
class MainFrame
    : public MessageSubscriber
{
public:
	MainFrame(void);
	virtual ~MainFrame(void);
	void run();
protected:
	//React to keyboard behavior.
	void keyboardListener();
    virtual bool fire();
    void showWorld() const;
    void showDemoOne();
    void showConveyerBelt();
    void showGun();
    void showStraightLine();
    void showDoubleStraightLine();
    void showRectangle();
    void configLoopTime();
    void configWorldSize();
    void configLife();
    void runConfigWorld();
    void runRandomWorld();
    void resumeLast();
private:
	size_t loopTime;
    std::auto_ptr<World> world;
    MainMenu mainMenu;
    DemoMenu demoMenu;
    AboutDialog aboutDialog;
};
